﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThresholdAssistant.DataContract.Result;
using ThresholdAssistant.WebAPI.Models;
using ThresholdAssistant.WebAPI.Service;

namespace ThresholdAssistant.WebAPI.Controllers
{
    /// <summary>
    /// 数组控制器
    /// </summary>
    [Route("api/site")]
    public class SiteController : BaseController
    {
        /// <summary>
        /// 数组服务
        /// </summary>
        public SiteService SiteService { get; set; }

        /// <summary>
        /// 获取数组列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-list")]
        [AllowAnonymous]
        public async Task<ContractResult<IEnumerable<SiteData>>> GetListAsync(GetSiteListParam param)
        {
            return await SiteService.GetListAsync(param);
        }

        /// <summary>
        /// 新增数组
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("add")]
        [AllowAnonymous]
        public async Task<ContractResult<long>> AddAsync(AddSiteParam param)
        {
            return await SiteService.AddAsync(param);
        }

        /// <summary>
        /// 获取数组信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-info")]
        public async Task<ContractResult<SiteData>> GetInfoAsync(GetSiteInfoParam param)
        {
            return await SiteService.GetInfoAsync(param);
        }

        /// <summary>
        /// 删除数组信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("delete")]
        [AllowAnonymous]
        public async Task<ContractResult> DeleteAsync(DeleteSiteParam param)
        {
            return await SiteService.DeleteAsync(param);
        }

        /// <summary>
        /// 修改数组
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("update")]
        [AllowAnonymous]
        public async Task<ContractResult> UpdateAsync(UpdateSiteParam param)
        {
            return await SiteService.UpdateAsync(param);
        }


    }
}